/**
 * -----------------------------------------------------------------
 * 关系实例
 */

class Person {
  constructor(name, house) {
    this.name = name;
    this.house = house;
  }
  say() {
    alert(`${this.name} is eating`)
  }
}

class House {
  constructor(city) {
    this.city = city;
  }
  showCity(){
    alert(`House in ${this.city}`)
  }
}

class A extends Person {
  constructor(name, house) {
    super(name, house)
  }
  saySomething() {
    this.house.showCity()
    // alert(`${this.name} in ${this.house.city}`)
  }
}

class B extends Person {
  constructor(name, house) {
    super(name, house)
  }
  saySomething() {
    alert("Im B")
  }
}

let aHouse = new House('Beijing')
let a = new A('a', aHouse)
a.saySomething()
